home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4399 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.eden.com!usenet
  2. From: "Shane M. Sadler" <nexus@eden.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: kbhit and getche loop
  5. Date: Sat, 03 Feb 1996 23:38:41 -0600
  6. Organization: Eden Matrix
  7. Message-ID: <31144661.1419@eden.com>
  8. References: <4f119f$7e7@jupiter.planet.net>
  9. NNTP-Posting-Host: net-1-110.austin.eden.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b5 (Win95; I)
  14.  
  15. Chris Kemp wrote:
  16. > I have the following code which I want to take characters from the stdin, and
  17. > append them onto a commandstring.  [snip]
  18.  
  19. > I think my problem is in processing the ch character, or perhaps comparing it to
  20. > '/n'.  
  21. > If anyone has some thoughts about hot to do this, I'd sure would like a good
  22. > suggestion.
  23. > [snip]
  24.  
  25. >                 int ch;
  26. >                 char *charget;
  27. >                 ch=getche();
  28. >                 *charget=ch;
  29. >                 strcat(commandstring,charget);
  30. >                 if (ch=='/n') {
  31. >                     parse(commandstring, delimiter);   //separate it into tokens
  32. > store in parsedarray[MAXWORDS][SIZE]
  33. >                     processcommandincommandstring();
  34. >                }
  35. >  } while (0 EQ 0); //infinite loop
  36.  
  37. What sort of error are you getting? One problem just might be that you're 
  38. checking for '/n'. Are you trying to check for '\n' perhaps? I can't tell 
  39. from your snippet: is there a reason why you don't want to just read in whole 
  40. strings (using gets() or whatever you want) and concatenate the whole mess 
  41. into commandstring using sprintf() (okay, or strcat())instead of reading it 
  42. in character-by-character?
  43.  
  44. Cheers,
  45. Shane
  46.